package cn.hd.authorService.service.log.impl;

import cn.hd.authorService.mapper.SystemLogMapper;
import cn.hd.authorService.service.log.SystemLogService;
import cn.hd.commonService.entity.SystemLog;import cn.hd.commonService.utils.DateUtils;
import cn.hd.commonService.vo.Query;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SystemLogServiceImpl extends ServiceImpl<SystemLogMapper, SystemLog> implements SystemLogService {

    @Autowired
    private SystemLogMapper systemLogMapper;

    @Override
    public IPage<SystemLog> getListByPage(Query query) {
        Page<SystemLog> page = new Page<>(query.getCurrentPage(),query.getPageSize());
        Page<SystemLog> logPage = systemLogMapper.selectPage(page, null);
        for (SystemLog systemLog : logPage.getRecords()) {
            systemLog.setStartTimeDesc(DateUtils.longToStr(systemLog.getStartTime()));
            systemLog.setEndTimeDesc(DateUtils.longToStr(systemLog.getEndTime()));
        }
        return logPage;
    }
}
